<table width="100%"><tr><td width="20%">
<a href="../index.html">&lt; index</a><br />
<a href="index.html">&lt; 2. Console</a><br />
<a href="console_keyboard.html">&lt; 2.3 Handling keyboard input</a>
</td><td width="60%">
<p align="center">
=====================================<br />
2.3.1 Blocking keyboard input<br />
=====================================<br />
</p></td><td width="20%">
</td></tr></table>
<style type="text/css">
.code { color:#444444; background-color:#EEEEEE;}
pre { color:#444444; background-color:#EEEEEE;}
table.param td { border : 1px solid #000000; }
th { background-color: #44BBFF; color: #FFFFFF }
table.none td { border : 0 }
</style>
<p class="code"><pre>
C++ : static TCOD_key_t TCODConsole::waitForKeypress(bool flush)
C   : TCOD_key_t TCOD_console_wait_for_keypress(bool flush)
Py  : console_wait_for_keypress(flush)
</pre></p>
<br />
This function waits for the user to press a key. It returns the code of the key pressed as well as the corresponding character. See <a href="key_t.html">TCOD_key_t</a>.<br />
If the flush parameter is true, every pending keypress event is discarded, then the function wait for a new keypress.<br />
If flush is false, the function waits only if there are no pending keypress events, else it returns the first event in the keyboard buffer.<br /> 
<table class="param">
<tr><th>Parameter</th><th>Description</th></tr>
<tr><td>flush</td><td>If true, all pending keypress events are flushed from the keyboard buffer. Else, return the first available event.</td></tr>
</table>
<br />
Example :<br />
<p class="code"><pre>
C++ : TCOD_key_t key = TCODConsole::waitForKeypress(true);
      if ( key.c == 'i' ) { ... open inventory ... }
C   : TCOD_key_t key = TCOD_console_wait_for_keypress(true);
      if ( key.c == 'i' ) { ... open inventory ... }
Py  : key = libtcod.console_wait_for_keypress(True)
      if key.c == ord('i') : # ... open inventory ...
</pre></p>
